/**
 * 广告主api
 */
angular.module('imsApp').factory('AppManager', ['$http', 'api','paramsManager', function ($http,api, paramsManager) {
    var AppManager = {
        /**
         * 获取应用列表
         params:[pageNo,pageSize]//顺序不能错
         query{keyword,status,appType,channelId}
         */
        appList: function (params,query) {
            return $http.get(api+"/ims/apps/"+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         *
          应用添加
         * @param {userName:"xxxx"}
         * @returns {*}
         */
        appAdd: function (params) {
            return $http.post(api+'/ims/apps',params).then(function (result) {
                return result;
            });
        },
        /**
         *应用详情
         * @param appId
         * @returns
         */
        appDeatil: function (appId) {
            return $http.get(api+'/ims/apps/'+appId).then(function (result) {
                return result;
            });
        },
        /**
         *应用删除
         * @param ids []
         * @returns
         */
        appDelete: function (ids) {
            return $http.delete(api+'/ims/apps/'+ids.join(",")).then(function (result) {
                return result;
            });
        },
        /**
         *应用修改
         * @param appId params
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        appEdit: function (appId,params) {
            return $http.put(api+'/ims/apps/'+appId,params).then(function (result) {
                return result;
            });
        },
        /**
         *应用统计

         */
        appStat: function (params,query) {
            return $http.get('/ims/apps/'+paramsManager.params(params)+paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         *应用状态修改
         * @param params 
         * @returns
         */
        appStatusEdit: function (appId, params) {
            return $http.put('/ims/apps/' + appId + '/status', params).then(function (result) {
                return result;
            });
        }

}



    return AppManager;
}]);
